<template>
    <!-- 修改资料 -->

    <div>
        <el-form label-width="85px" :model="form" label-position="right" ref="formRef" :rules="formRules" disabled class="borderNone">
            <tsCard header="基本信息">
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="编号" prop="number">
                            <el-input v-model="form.number"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="标题" prop="name">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="副标题" prop="subtitle">
                            <el-input v-model="form.subtitle"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="发布时间" prop="effectDateTime">
                            <el-input v-model="form.effectDateTime"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="内容类别" prop="category">
                            <el-input v-model="form.categoryName"/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="细分级别" prop="subCategory" v-if="form.categoryName">
                            <el-input v-model="form.subCategoryName"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="星级类别" prop="starRating">
                            <el-rate v-model="form.starRating" allow-half />
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="顺序号" prop="itemIndex">
                            <el-input-number v-model="form.itemIndex" :min="0" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="自定义1" prop="customer1">
                            <el-input v-model="form.customer1"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="自定义2" prop="customer2">
                            <el-input v-model="form.customer2"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="自定义3" prop="customer3">
                            <el-input v-model="form.customer3"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="自定义4" prop="customer4">
                            <el-input v-model="form.customer4"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="状态" prop="status">
                            <el-switch v-model="form.status" size="large" inline-prompt active-value="normal"
                                inactive-value="disable" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                        <el-form-item label="备注" prop="remark">
                            <div v-html="form.remark"></div>
                        </el-form-item>
                    </el-col>
                </el-row>
            </tsCard>
        </el-form>
            <tsCard header="上传附件">
                <tsFormTable v-model="dataList" disabled>
                    <template #tableContent>
                        <el-table-column  label="图片" width="100">
                            <template #default="scope"> 
                                <el-image v-if="checkType(scope.row) == 'image'" alt="上传图片" :preview-src-list="srcList" preview-teleported :src="scope.row.fileFullPath" 
                                    @click="openDialog(scope.row.fileFullPath)"></el-image>
                                <video v-else-if="checkType(scope.row) == 'video'" :src="scope.row.fileFullPath" controls
                                    style="width: 100%;height: 100%;"></video>
                                <span v-else>{{ getFileName(scope.row) }}</span>    
                            </template>
                        </el-table-column>
                        <el-table-column prop="fileKind" label="类别">
                            <template #default="scope">
                                <span >{{scope.row.fileKindName}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="itemIndex" label="排序">
                            <template #default="scope">
                                <span>{{ scope.row.itemIndex }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="remark" label="备注">
                            <template #default="scope">
                                <span>{{ scope.row.remark }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="remark" label="状态">
                            <template #default="scope">
                                <el-switch v-model="scope.row.status" size="large" disabled inline-prompt active-value="normal"
                                    inactive-value="disable" />
                            </template>
                        </el-table-column>
                    </template>
                </tsFormTable>
            </tsCard>
        

        <!-- </template> -->
        <!-- <template #footer> -->
        <div class="button-position">
            <el-button @click="updateVisible">取 消</el-button>
            <el-button type="primary" @click="addProduct(formRef)">确 定</el-button>
        </div>
        <!-- </template> -->

        <!-- </myDialog> -->
    </div>
</template>


<script setup>
import { reactive, ref, onMounted } from 'vue';
import { ElNotification } from 'element-plus';
import Api from '@/api/model/system'
import tsFormTable from '@/components/scFormTable/index.vue'
import tsCard from '@/components/tsCard/index.vue'
import {checkType} from '@/utils/checkType.js'
const emit = defineEmits(['updatetable'])
const props = defineProps({
    paramsData: {
        type: Object,
        defalut: {}
    }
})

// 添加用户数据的对象
const form = ref({
});
const srcList = ref([])
const dataList = ref([])
onMounted(() => {
    getInit()
})
const openDialog = (val) =>{
    srcList.value.unshift(val)
}
const updateVisible = () => {
    emit('updatetable');
}

const getInit = async () => {
    let res = await Api.content.detail.post(props.paramsData);
    if (res.code == '200') {
        form.value = res.data
        dataList.value = res.dataList
    }

}

// 上传
</script>

<style scoped lang="less">
.borderNone {
    :deep(.el-input__wrapper) {
        box-shadow: 0 0 0 0px var(--el-input-border-color, var(--el-border-color)) inset;
        cursor: default;
        background-color: transparent; //背景颜色透明
        border-bottom: 1px solid #999;
        border-radius: 0;

        .el-input__inner {
            cursor: default !important;
        }
    }
}
</style>

